# Maintainer: Andreas 'Segaja' Schleifer <segaja at archlinux dot org>

pkgname='certbot-dns-inwx'
pkgver=2.2.0
pkgrel=3
pkgdesc="INWX DNS authenticator plugin for certbot"
arch=('any')
url="https://github.com/oGGy990/certbot-dns-inwx"
license=('Apache')
depends=('certbot' 'python')
makedepends=('python-build' 'python-installer' 'python-wheel')
source=("${url}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha512sums=('67f40b50823f11c92750d5e961eb452b9cfde57a0a6c19863e07828f082615cc2a0282eb3d7c6c4ed192557dbaeeef7e2e98f1857b228557f1259e1a7ec0acc3')
backup=(
  'etc/letsencrypt/inwx.cfg'
)

build() {
  cd "${pkgname}-${pkgver}"

  python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${pkgname}-${pkgver}"

  local _site_packages="$(python -c "import site; print(site.getsitepackages()[0])")"

  python -m installer --destdir="${pkgdir}" dist/*.whl

  install --verbose -D --mode=0600 inwx.cfg "${pkgdir}/etc/letsencrypt/inwx.cfg"
  install --verbose -D --mode=0644 README.md --target-directory "${pkgdir}/usr/share/doc/${pkgname}"

  # remove unneeded config file from site-packages
  rm --recursive --verbose "${pkgdir}${_site_packages}/etc"
}
